package com.threeti.mecool.core.domain.model.acl;

import java.util.Collections;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.threeti.jiayusms.framework.domain.support.DefaultDomainEntity;

/** 角色 */
@Entity
@Table(name = "DM_ROLE")
public class Role extends DefaultDomainEntity {
  private String name;
  
  @ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
  @JoinTable(name = "DM_ROLE_PERMISSION", joinColumns = { @JoinColumn(name = "ROLE_ID") }, inverseJoinColumns = { @JoinColumn(name = "PERMISSION_ID") })
  @Fetch(FetchMode.SUBSELECT)
	private List<Permission> permissions;

  public String getName() {
    return name;
  }

  public List<Permission> getPermissions() {
    return Collections.unmodifiableList(permissions);
  }
  
  
  
}
